@extends('admin.master')

@section('title', '历史记录')
	
@section('firstItem')
@parent
				<span class="linkBtn" onclick="window.location.href='/admin/device/index'">设备列表</span> &raquo; 
				<span>历史记录</span>
				<input class="a_indexbg" type="hidden" value="devicelist" />
				
@stop
@section('searchList')
@parent
				<a class="aaa">搜索</a>
				<div>水机状态		
					<input type="text" class="deviceCheckBox deviceStatusCheckBox" value="{{ $status or '' }}" placeholder="全部" />
					<div class="deviceCheckDropBox deviceStatusCheckDropBox">
						<a>全部</a>
						<a>正常</a>
						<a>检修</a>
						<a>缺水</a>
						<a>漏水</a>
					</div>
				</div>
@stop
@section('dataTables')
@parent
			<table class="dataHistoryNote dataTables dataTable" cellspacing="0" cellpadding="0">
				<thead>
					<tr>
						<td>序号</td>
						<td>设备编号</td>
						<td>PH酸碱值</td>
						<td>滤芯1</td>
						<td>滤芯2</td>
						<td>滤芯3</td>
						<td>滤芯4</td>
						<td>纯水TDS</td>
						<td>原水TDS</td>
						<td>水机状态</td>
						<td>记录时间</td>
					</tr>
				</thead>
				<tbody>
					@for($i=0, $recordCount=count($device_records); $i<$recordCount; $i++)
						<tr >
						<td>{{ $i+1 }}</td>
						<td class="devicecodeVal">{{ $device_records[$i]->device->code }}</td>
						<td >{{ $device_records[$i]->ph_value }}</td>
						@for($j=1; $j< 5; $j++)
							<?php $filter = 'filter'.$j?>
							@if($device_records[$i]->$filter <= 10)
						<td class="filterWidth fontColor">
							@else
						<td class="filterWidth">
							@endif
						{{ $device_records[$i]->$filter }}%</td>
						@endfor
						<td>{{ $device_records[$i]->TDS2 }}</td>
						<td>{{ $device_records[$i]->TDS1 }}</td>
						@if($device_records[$i]->dec_status == 2)
						<td class="lessWaterBg">
						@elseif($device_records[$i]->dec_status == 4)
						<td class="serviceBg">
						@elseif($device_records[$i]->dec_status == 8)
						<td class="leakBg">
						@else
						<td>
						@endif
						{{ $device_records[$i]->device_status_description }}</td>
						<td>{{ $device_records[$i]->created_at }}</td>
					</tr>
					@endfor
				</tbody>
			</table>
@stop
@section('page_num')
<ul class="pagination pagination-lg"> 
@if(count($device_records))
	<?php
	$queryParam = ['device_id' => $device_id];
	$queryParam = empty($status)? $queryParam: array_merge($queryParam, ['status' => $status])?>
	{!! $device_records->appends($queryParam)->render() !!}
@endif
</ul>
@stop
@section('infor_promit')
@parent	

@stop

<script>
	window.onload=function(){
		$(".devicelist").css("backgroundColor","#D83030").siblings().css("backgroundColor","#101113");
		//查询水机状态下拉框
		$(".deviceStatusCheckBox").click(function(event){
			event.stopPropagation();
			$(".deviceStatusCheckDropBox").show();
			$(".deviceStatusCheckDropBox a").unbind('click').click(function(){
				$(".deviceStatusCheckBox").val($(this).html());
				$(".deviceStatusCheckDropBox").hide();
			});
			$("body").unbind('click').click(function(){
				$(".deviceStatusCheckDropBox").hide();
			});
		});
		//搜索
		$(".searchList > a").click(function(){
			var status = $(".deviceCheckBox").val();
			window.location.href="/admin/device/history?&status="+status+"&device_id={{ $device_id or '' }}";
		});
	}
	
					
</script>